import React from 'react'
import { SimpleSelector } from './simpleSelector'
import { WaitTypeProvider } from '../../consts/waitType'

export const WaitTypeSelector = ({ inputClassName, initValue, onSelectItem, readOnly }) => {
    const dataSource = WaitTypeProvider.getAllWaitTypes().filter(Boolean)
    const getItemValue = React.useCallback(item => item.code, [])
    const renderItem = React.useCallback(item => `${item.code}[${item.title}]`, [])
    const filterDataSource = React.useCallback(value => item => renderItem(item).toUpperCase().includes(value), [])

    return <SimpleSelector inputClassName={inputClassName} dataSource={dataSource} filterDataSource={filterDataSource}
        getItemValue={getItemValue} initValue={initValue} onSelectItem={onSelectItem}
        readOnly={readOnly} renderItem={renderItem} />
}